package com.ck.roomdemo;

import android.app.Application;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.ViewModel;
import androidx.room.Room;

import com.ck.roomdemo.room.MyDatabase;
import com.ck.roomdemo.room.Student;
import com.ck.roomdemo.room.StudentDao;

import java.util.List;
import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class MyViewModel extends AndroidViewModel {
    private MyRepository myRepository;

    public MyViewModel(@NonNull Application application) {
        super(application);
        myRepository = new MyRepository(application);
    }

    public LiveData<List<Student>> getLiveData() {
        return myRepository.getLiveData();
    }

    public void insert(Student...students) {
        myRepository.insert(students);
    }

    public void update(Student student) {
        myRepository.update(student);
    }

    public void delete(Student student) {
        myRepository.delete(student);
    }

    public void clear() {
        myRepository.clear();
    }
}
